using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DodgeState : State
{

    protected D_DodgeState stateData;

    protected bool performCloseRangeAction;
    protected bool isPlayerInMaxAgroRange;

    protected bool isGrounds;
    protected bool isDodgeOver;

    public DodgeState(Entity entity, FiniteStateMachine startMachine, string animBoolName, D_DodgeState stateData) : base(entity, startMachine, animBoolName)
    {
        this.stateData = stateData;
    }

    public override void DoChecks()
    {
        base.DoChecks();
        performCloseRangeAction = entity.CheckPlayerInCloseRangeAction();
        isPlayerInMaxAgroRange = entity.CheckPlayerInMaxAgroRange();
        isGrounds = CollisionSenses.Ground;
    }

    public override void Enter()
    {
        base.Enter();
        isDodgeOver = false;
        Movement.SetVelocity(stateData.dodgeSpeed, stateData.dodgeAngle, -Movement.FacingDirection);
    }

    public override void Exit()
    {
        base.Exit();
    }

    public override void logicUpdate()
    {
        base.logicUpdate();

        if (Time.time>=startTime+stateData.dodgeTime&&isGrounds)
        {
            isDodgeOver = true;
        }

    }

    public override void PhysicsUpdate()
    {
        base.PhysicsUpdate();
    }
}
